package com.kateba.android.hid;

import com.kateba.android.blueinput.Singleton;


public class HidParser
{
  static final int HID_ITEM_LENGTH_MASK = 3;
  static final int HID_ITEM_TAG_MASK = 240;
  static final int HID_ITEM_TAG_SHIFT = 4;
  static final int HID_ITEM_TYPE_MASK = 12;
  static final int HID_ITEM_TYPE_SHIFT = 2;
  static final int HID_LONG_ITEM = 254;
  static final int MAX_EK_KEYS = 255;
  static final int MAX_HID_COLLECTIONS = 10;
  static final int MAX_HID_INPUTS = 20;
  static final int MAX_HID_REPORTS = 10;
  static final int MAX_INPUT_USAGES = 20;
  final String LOG_TAG = "BlueInput::HidParser";
  int m_nCollections;
  int m_nReports;
  _TOPCOLLECTION[] m_pCollections;
  _LAST m_pLast;
  _HIDREPORT[] m_pReports;
  public Action poutAction = new Action();
private int i14;

  public HidParser()
  {
    Init();
  }

  void Deinit()
  {
    if ((this.m_pLast.pUsages != null) && (this.m_pLast.nUsages > 0))
      this.m_pLast.nUsages = 0;
    if ((this.m_pCollections != null) && (this.m_nCollections > 0))
      this.m_nCollections = 0;
    int i = 0;
    if (i >= this.m_nReports)
    {
      if ((this.m_pReports != null) && (this.m_nReports > 0))
        this.m_nReports = 0;
      Singleton.getInstance().Debug("BlueInput::HidParser", "Deinit done.");
      return;
    }
    for (int j = 0; ; j++)
    {
      if (j >= this.m_pReports[i].nInputs)
      {
        if ((this.m_pReports[i].pInputs != null) && (this.m_pReports[i].nInputs > 0))
          this.m_pReports[i].nInputs = 0;
        i++;
        break;
      }
      if ((this.m_pReports[i].pInputs[j].pUsages == null) || (this.m_pReports[i].pInputs[j].nUsages <= 0))
        continue;
      this.m_pReports[i].pInputs[j].nUsages = 0;
    }
  }

  int GetBitValue(byte[] paramArrayOfByte, int paramInt1, int paramInt2, int paramInt3)
  {
    int i = 0;
    for (int j = paramInt2; ; j++)
    {
      if (j >= paramInt2 + paramInt3)
        return i;
      int k = j / 8;
      int m = j % 8;
      if ((0xFF & paramArrayOfByte[k] & 1 << m) == 0)
        continue;
      i |= 1 << j - paramInt2;
    }
  }

  int GetData(byte[] paramArrayOfByte, int paramInt1, int paramInt2)
  {
    int i = 0;
    int j = 0;
    if (j >= paramInt2);
    while (true)
    {
      if (j >= 4)
      {
//        return i;
        i = (0xFF & paramArrayOfByte[(paramInt1 + j)]) << 24 | i >>> 8;
        j++;
        break;
      }
      i >>>= 8;
      j++;
    }
	return j;
  }

  int GetDataSize(int paramInt)
  {
    int i;
    if (paramInt == 254)
      i = 254;
    while (true)
    {
  //    return i;
      i = paramInt & 0x3;
      if (i != 3)
        continue;
      i = 4;
    }
  }

  int Init()
  {
    this.m_pReports = new _HIDREPORT[1];
    this.m_pReports[0] = new _HIDREPORT();
    this.m_nReports = 0;
    Singleton.getInstance().Debug("BlueInput::HidParser", "Init called, m_pReports=" + this.m_pReports);
    Singleton.getInstance().Debug("BlueInput::HidParser", "m_pReports[0]=" + this.m_pReports[0]);
    this.m_pReports[0].pInputs = new _INPUT[1];
    this.m_pReports[0].pInputs[0] = new _INPUT();
    this.m_pReports[0].pInputs[0].pUsages = new int[1];
    this.m_pReports[0].nInputs = 0;
    this.m_pReports[0].usagepage = 0;
    this.m_pReports[0].usage = 0;
    this.m_pReports[0].id = 0;
    this.m_pReports[0].collection = 0;
    this.m_pCollections = new _TOPCOLLECTION[1];
    this.m_pCollections[0] = new _TOPCOLLECTION();
    this.m_nCollections = 0;
    this.m_pLast = new _LAST();
    this.m_pLast.pUsages = new int[1];
    this.m_pLast.nUsages = 0;
    Singleton.getInstance().Debug("BlueInput::HidParser", "Init done.");
    return 1;
  }

  public int ParseBootReport(byte[] paramArrayOfByte, int paramInt)
  {
    Singleton.getInstance().Debug("BlueInput::HidParser", ">>> HidParser::ParseBootReport " + paramInt);
    int i4;
    if (paramInt < 6)
    {
      i4 = 0;
      return i4;
    }
    int i = paramArrayOfByte[1];
    int j = 0;
    //label68:
    int i9=0;
    int i10=0;
    //label149:
    int i7=0;
    int i8 = 0;
//    label221:
    	int i2 = 0;
    int i3 = 0;
    int i5 = 0;
    if ((i == 1) || (this.poutAction.DevType == 0))
    {
      this.poutAction.KB_Modifier = paramArrayOfByte[2];
      j = 4;
      if (j >= paramInt)
        this.poutAction.KB_BufSize = (paramInt - 4);
    }
    else if ((i == 2) || (this.poutAction.DevType == 1))
    {
      this.poutAction.Mouse_Buts = paramArrayOfByte[2];
      int k = GetBitValue(paramArrayOfByte, paramInt, 24, 8);
      int m = 0;
      if ((k & 0x80) != 0)
        m = 1;
      if (m == 1)
      {
        i9 = 0;
        i10 = 0;
        if (i10 < 8)
//          break label351;
        k ^= i9;
      }
      this.poutAction.Mouse_X = (k * (1 - m * 2));
      int n = GetBitValue(paramArrayOfByte, paramInt, 24 + 8, 8);
      int i1 = 0;
      if ((n & 0x80) != 0)
        i1 = 1;
      if (i1 == 1)
      {
        i7 = 0;
        i8 = 0;
        if (i8 < 8)
//          break label365;
        n ^= i7;
      }
      this.poutAction.Mouse_Y = (n * (1 - i1 * 2));
      i2 = GetBitValue(paramArrayOfByte, paramInt, 8 + 32, 8);
      i3 = 0;
      if ((i2 & 0x80) != 0)
        i3 = 1;
      if (i3 == 1)
        i5 = 0;
    }
    for (int i6 = 0; ; i6++)
    {
      if (i6 >= 8)
      {
        i2 ^= i5;
        this.poutAction.Mouse_Wheel = (i2 * (1 - i3 * 2));
        i4 = 1;
//        break;
        this.poutAction.KB_BufKeys[(j - 4)] = paramArrayOfByte[j];
        j++;
//        break label68;
//        label351:
        	i9 = 0x1 | i9 << 1;
        i10++;
//        break label149;
//        label365: 
        	i7 = 0x1 | i7 << 1;
        i8++;
//        break label221;
      }
      i5 = 0x1 | i5 << 1;
    }
  }

  public int ParseRD(byte[] paramArrayOfByte, int paramInt)
  {
    Singleton.getInstance().Debug("BlueInput::HidParser", "ParseRD call RDSize=" + paramInt);
    Deinit();
    Init();
    Singleton.getInstance().Debug("BlueInput::HidParser", "ParseRD memory allocation ok.");
    this.m_nCollections = 0;
    this.m_nReports = 0;
    int i = 0;
    int j = 0;
    int k = 0;
    int i13 = 0;
    if (k >= paramInt)
    {
      Singleton.getInstance().Debug("BlueInput::HidParser", "TOP Collections=" + this.m_nCollections);
      i13 = 0;
      if (i13 >= this.m_nCollections)
        return 1;
    }
    else
    {
      int m = 0xFF & paramArrayOfByte[k];
      int n = GetDataSize(m);
      if (n == 254)
        n = 1 + paramArrayOfByte[(k + 1)];
      int i1 = 0;
      int i11;
      int i12 = 0;
//      label208: 
    	  int i4;
      do
      {
        k += n + 1;
//        break;
        i1 = GetData(paramArrayOfByte, k + 1, n);
        int i2 = 0;
        if ((i1 & 1 << -1 + n * 8) > 0)
          i2 = 1;
        int i3 = i1;
        if (i2 == 1)
        {
          i11 = 0;
          i12 = 0;
          if (i12 < n * 8)
//            break label2012;
          i3 ^= i11;
        }
        i4 = m >>> 2;
        if ((i4 == 1) && (i == 0))
          this.m_pCollections[this.m_nCollections].usagepage = i1;
        if ((i4 == 2) && (i == 0))
          this.m_pCollections[this.m_nCollections].usage = i1;
        if (i4 == 40)
        {
          i++;
          this.m_pLast.nUsages = 0;
        }
        if (i4 == 48)
        {
          if (i == j)
          {
            if (this.m_pReports[this.m_nReports].usagepage == 0)
              this.m_pReports[this.m_nReports].usagepage = this.m_pCollections[this.m_nCollections].usagepage;
            if (this.m_pReports[this.m_nReports].usage == 0)
              this.m_pReports[this.m_nReports].usage = this.m_pCollections[this.m_nCollections].usage;
            this.m_nReports = (1 + this.m_nReports);
            _HIDREPORT[] arrayOf_HIDREPORT1 = new _HIDREPORT[1 + this.m_nReports];
            System.arraycopy(this.m_pReports, 0, arrayOf_HIDREPORT1, 0, this.m_pReports.length);
            this.m_pReports = arrayOf_HIDREPORT1;
            _HIDREPORT[] arrayOf_HIDREPORT2 = this.m_pReports;
            int i10 = this.m_nReports;
            _HIDREPORT local_HIDREPORT2 = new _HIDREPORT();
            arrayOf_HIDREPORT2[i10] = local_HIDREPORT2;
            Singleton.getInstance().Debug("BlueInput::HidParser", "ParseRD realloc m_pReports=" + this.m_pReports);
            this.m_pReports[this.m_nReports].pInputs = new _INPUT[1];
            _INPUT[] arrayOf_INPUT3 = this.m_pReports[this.m_nReports].pInputs;
            _INPUT local_INPUT2 = new _INPUT();
            arrayOf_INPUT3[0] = local_INPUT2;
            this.m_pReports[this.m_nReports].pInputs[0].pUsages = new int[1];
            this.m_pReports[this.m_nReports].nInputs = 0;
            this.m_pReports[this.m_nReports].usage = 0;
            this.m_pReports[this.m_nReports].usagepage = 0;
            this.m_pReports[this.m_nReports].id = 0;
            this.m_pReports[this.m_nReports].collection = 0;
            j = 0;
          }
          i--;
          if (i == 0)
          {
            this.m_nCollections = (1 + this.m_nCollections);
            _TOPCOLLECTION[] arrayOf_TOPCOLLECTION1 = new _TOPCOLLECTION[1 + this.m_nCollections];
            System.arraycopy(this.m_pCollections, 0, arrayOf_TOPCOLLECTION1, 0, this.m_pCollections.length);
            this.m_pCollections = arrayOf_TOPCOLLECTION1;
            _TOPCOLLECTION[] arrayOf_TOPCOLLECTION2 = this.m_pCollections;
            int i9 = this.m_nCollections;
            _TOPCOLLECTION local_TOPCOLLECTION = new _TOPCOLLECTION();
            arrayOf_TOPCOLLECTION2[i9] = local_TOPCOLLECTION;
            Singleton.getInstance().Debug("BlueInput::HidParser", "ParseRD realloc m_pCollections=" + this.m_pCollections);
          }
        }
        if (((i4 == 1) || (i4 == 33)) && (i > 0))
          j = i;
        if (i4 == 33)
        {
          Singleton.getInstance().Debug("BlueInput::HidParser", "ParseRD new REPORTID (tag 0x21) found, index=" + this.m_nReports + ", rdepth=" + i + ", prev=" + this.m_pReports[this.m_nReports].id);
          if (this.m_pReports[this.m_nReports].id == 0)
          {
            this.m_pReports[this.m_nReports].collection = this.m_nCollections;
            this.m_pReports[this.m_nReports].id = i1;
          }
        }
        if ((i4 == 29) && (j > 0))
          this.m_pLast.sizebits = i1;
        if ((i4 == 37) && (j > 0))
          this.m_pLast.sizecount = i1;
        if ((i4 == 1) && (j > 0))
          this.m_pLast.usagepage = i1;
        if ((i4 == 6) && (j > 0))
          this.m_pLast.usagemin = i1;
        if ((i4 == 10) && (j > 0))
          this.m_pLast.usagemax = i1;
        if ((i4 == 5) && (j > 0))
          this.m_pLast.logicalmin = (i3 * (1 - i2 * 2));
        if ((i4 == 9) && (j > 0))
          this.m_pLast.logicalmax = (i3 * (1 - i2 * 2));
        if ((i4 != 2) || (j <= 0))
          continue;
        this.m_pLast.pUsages[this.m_pLast.nUsages] = i1;
        _LAST local_LAST = this.m_pLast;
        local_LAST.nUsages = (1 + local_LAST.nUsages);
        int[] arrayOfInt3 = new int[1 + this.m_pLast.nUsages];
        System.arraycopy(this.m_pLast.pUsages, 0, arrayOfInt3, 0, this.m_pLast.nUsages);
        this.m_pLast.pUsages = arrayOfInt3;
        Singleton.getInstance().Debug("BlueInput::HidParser", "ParseRD realloc m_pLast.pUsages=" + this.m_pLast.pUsages + ", added usage=" + i1);
      }
      while (i4 != 32);
      int i5 = this.m_pReports[this.m_nReports].nInputs;
      Singleton.getInstance().Debug("BlueInput::HidParser", "ParseRD new INPUT(0x20) found, current index=" + i5);
//      label1244:
    	  int i8 = 0;
      if (this.m_pLast.usagepage == 0)
      {
        this.m_pReports[this.m_nReports].pInputs[i5].usagepage = this.m_pCollections[this.m_pReports[this.m_nReports].collection].usagepage;
        this.m_pReports[this.m_nReports].pInputs[i5].usagemin = this.m_pLast.usagemin;
        this.m_pReports[this.m_nReports].pInputs[i5].usagemax = this.m_pLast.usagemax;
        this.m_pReports[this.m_nReports].pInputs[i5].logicalmin = this.m_pLast.logicalmin;
        this.m_pReports[this.m_nReports].pInputs[i5].logicalmax = this.m_pLast.logicalmax;
        this.m_pReports[this.m_nReports].pInputs[i5].sizebits = this.m_pLast.sizebits;
        this.m_pReports[this.m_nReports].pInputs[i5].sizecount = this.m_pLast.sizecount;
        Singleton.getInstance().Debug("BlueInput::HidParser", "*** ParseRD new INPUT Params(" + this.m_pLast.usagepage + "," + this.m_pLast.usagemin + "," + this.m_pLast.usagemax + "," + this.m_pLast.logicalmin + "," + this.m_pLast.logicalmax + "," + this.m_pLast.sizebits + "," + this.m_pLast.sizecount + ") Usages=" + this.m_pLast.nUsages + " Report ID=" + this.m_pReports[this.m_nReports].id);
        int[] arrayOfInt2 = null;
		if (this.m_pLast.nUsages <= 0)
         // break label2091;
         arrayOfInt2 = new int[1 + this.m_pLast.nUsages];
        this.m_pReports[this.m_nReports].pInputs[i5].pUsages = arrayOfInt2;
        Singleton.getInstance().Debug("BlueInput::HidParser", "ParseRD realloc m_pReports[m_nReports=" + this.m_nReports + "].pInputs[inputindex=" + i5 + "].pUsages (1) ADDR=" + this.m_pReports[this.m_nReports].pInputs[i5].pUsages);
        i8 = 0;
//        label1661: 
//        	if (i8 < this.m_pLast.nUsages)
//          break label2054;
      }
      while (true)
      {
        Singleton.getInstance().Debug("BlueInput::HidParser", "ParseRD new INPUT usages done.");
        this.m_pReports[this.m_nReports].pInputs[i5].nUsages = this.m_pLast.nUsages;
        this.m_pReports[this.m_nReports].pInputs[i5].type = i1;
        this.m_pLast.usagepage = 0;
        this.m_pLast.nUsages = 0;
        this.m_pLast.usagemin = 0;
        this.m_pLast.usagemax = 0;
        this.m_pLast.logicalmin = 0;
        this.m_pLast.logicalmax = 0;
        this.m_pLast.sizebits = 0;
        this.m_pLast.sizecount = 0;
        Singleton.getInstance().Debug("BlueInput::HidParser", "ParseRD new INPUT last vars cleared.");
        _HIDREPORT local_HIDREPORT1 = this.m_pReports[this.m_nReports];
        local_HIDREPORT1.nInputs = (1 + local_HIDREPORT1.nInputs);
        _INPUT[] arrayOf_INPUT1 = new _INPUT[1 + this.m_pReports[this.m_nReports].nInputs];
        System.arraycopy(this.m_pReports[this.m_nReports].pInputs, 0, arrayOf_INPUT1, 0, this.m_pReports[this.m_nReports].pInputs.length);
        this.m_pReports[this.m_nReports].pInputs = arrayOf_INPUT1;
        _INPUT[] arrayOf_INPUT2 = this.m_pReports[this.m_nReports].pInputs;
        int i7 = this.m_pReports[this.m_nReports].nInputs;
        _INPUT local_INPUT1 = new _INPUT();
        arrayOf_INPUT2[i7] = local_INPUT1;
        Singleton.getInstance().Debug("BlueInput::HidParser", "ParseRD realloc m_pReports[m_nReports=" + this.m_nReports + "].pInputs " + this.m_pReports[this.m_nReports].pInputs);
        this.m_pReports[this.m_nReports].pInputs[(i5 + 1)].pUsages = new int[1];
//        break;
//        label2012: 
        //	i11 = 0x1 | i11 << 1;
        i12++;
      //  break label208;
        this.m_pReports[this.m_nReports].pInputs[i5].usagepage = this.m_pLast.usagepage;
//        break label1244;
//        label2054:
  this.m_pReports[this.m_nReports].pInputs[i5].pUsages[i8] = this.m_pLast.pUsages[i8];
        i8++;
//        break label1661;
        label2091: if (this.m_pLast.usagemax <= 0)
          continue;
        this.m_pLast.nUsages = (1 + (this.m_pLast.usagemax - this.m_pLast.usagemin));
        int[] arrayOfInt1 = new int[1 + this.m_pLast.nUsages];
        this.m_pReports[this.m_nReports].pInputs[i5].pUsages = arrayOfInt1;
        Singleton.getInstance().Debug("BlueInput::HidParser", "ParseRD realloc m_pReports[m_nReports=" + this.m_nReports + "].pInputs[inputindex=" + i5 + "].pUsages (2) ADDR=" + this.m_pReports[this.m_nReports].pInputs[i5].pUsages);
        for (int i6 = 0; i6 < this.m_pLast.nUsages; i6++)
          this.m_pReports[this.m_nReports].pInputs[i5].pUsages[i6] = (i6 + this.m_pLast.usagemin);
      }
    }
    Singleton.getInstance().Debug("BlueInput::HidParser", "TOP Collection[" + i13 + "]:Usagepage=" + this.m_pCollections[i13].usagepage + " Usage=" + this.m_pCollections[i13].usage);
    int i16 = 0;
    for (int i14 = 0; ; i14++)
    {
      int i15 = this.m_nReports;
      if (i14 >= i15)
      {
        i13++;
        break;
      }
      if (this.m_pReports[i14].collection != i13)
        continue;
      Singleton.getInstance().Debug("BlueInput::HidParser", "Has report: id=" + this.m_pReports[i14].id + " usage_page=" + this.m_pReports[i14].usagepage + " usage=" + this.m_pReports[i14].usage);
      i16 = 0;
      int i17 = this.m_pReports[i14].nInputs;
     // if (i16 < i17)
       // break label2477;
    }
//    label2477:
    	String str = "";
    if (this.m_pReports[i14].pInputs[i16].nUsages < 10);
    for (int i18 = 0; ; i18++)
    {
      int i19 = this.m_pReports[i14].pInputs[i16].nUsages;
      if (i18 >= i19)
      {
        Singleton.getInstance().Debug("BlueInput::HidParser", "Input: type=" + this.m_pReports[i14].pInputs[i16].type + " sizebits=" + this.m_pReports[i14].pInputs[i16].sizebits + " sizecount=" + this.m_pReports[i14].pInputs[i16].sizecount + " usage_page=" + this.m_pReports[i14].pInputs[i16].usagepage + " usage(min=" + this.m_pReports[i14].pInputs[i16].usagemin + ",max=" + this.m_pReports[i14].pInputs[i16].usagemax + ",count=" + this.m_pReports[i14].pInputs[i16].nUsages + ")(" + str + ")  vmin=" + this.m_pReports[i14].pInputs[i16].logicalmin + " vmax=" + this.m_pReports[i14].pInputs[i16].logicalmax);
        i16++;
        break;
      }
      str = str + " " + this.m_pReports[i14].pInputs[i16].pUsages[i18];
    }
	return i16;
  }

  public int ParseReport(byte[] paramArrayOfByte, int paramInt)
  {
    int i;
    if ((paramInt == 0) || (paramArrayOfByte == null))
      i = 0;
    int j;
//    label89: label95: 
    	int m;
    int n;
    int i1;
    int i2;
    while (true)
    {
//      return i;
      j = -1;
//      for (int k = 0; ; k++)
//      {
////        if (k >= this.m_nReports);
////        while (true)
////        {
////          Singleton.getInstance().Debug("BlueInput::HidParser", ">>> HidParser::ParseReport Index=" + j);
////          if (j != -1)
////     //       break label95;
////          i = 0;
//////          break;
////          if (this.m_pReports[k].id != paramArrayOfByte[1])
////       //     break label89;
////          j = k;
////        }
//      }
      m = 16;
      n = this.m_pReports[j].usagepage;
      i1 = this.m_pReports[j].usage;
      Singleton.getInstance().Debug("BlueInput::HidParser", "HidParser::ParseReport DeviceUsagePage=" + n + " DeviceUsage=" + i1);
      i2 = 0;
      if (i2 < this.m_pReports[j].nInputs)
        break;
      i = 1;
    }
    int[] arrayOfInt = new int['ÿ'];
    int i3 = 0;
    int i4 = 0;
    if ((this.m_pReports[j].pInputs[i2].type == 1) || (this.m_pReports[j].pInputs[i2].type == 3))
    {
      this.poutAction.DevType = -1;
      switch (n)
      {
      default:
      case 1:
      case 12:
      }
    }
    while (true)
    {
      if (i4 == 0)
//        break label626;
      if (this.m_pReports[j].pInputs[i2].usagepage == 7)
      {
        System.arraycopy(arrayOfInt, 0, this.poutAction.KB_BufKeys, 0, i3);
        this.poutAction.KB_BufSize = i3;
      }
      m += this.m_pReports[j].pInputs[i2].sizebits * this.m_pReports[j].pInputs[i2].sizecount;
      i2++;
//      break;
      if (this.m_pReports[j].pInputs[i2].type == 0)
      {
        i3 = this.m_pReports[j].pInputs[i2].sizecount;
        i4 = 1;
        for (int i32 = 0; i32 < i3; i32++)
          arrayOfInt[i32] = GetBitValue(paramArrayOfByte, paramInt, m + i32 * this.m_pReports[j].pInputs[i2].sizebits, this.m_pReports[j].pInputs[i2].sizebits);
      }
      i3 = this.m_pReports[j].pInputs[i2].nUsages;
      for (int i31 = 0; i31 < i3; i31++)
        arrayOfInt[i31] = GetBitValue(paramArrayOfByte, paramInt, m + i31 * this.m_pReports[j].pInputs[i2].sizebits, this.m_pReports[j].pInputs[i2].sizebits);
      if (i1 == 2)
      {
        this.poutAction.DevType = 1;
        continue;
      }
      if (i1 == 6)
      {
        this.poutAction.DevType = 0;
        continue;
      }
      if (i1 != 128)
        continue;
      this.poutAction.DevType = 3;
//      continue;
//      if (i1 != 1)
//        continue;
      this.poutAction.DevType = 2;
    }
//    label626:
    	int i5 = 0;
//    label629:
    	int i28;
    int i29;
    if (i5 < this.m_pReports[j].pInputs[i2].nUsages)
    {
      if (this.m_pReports[j].pInputs[i2].usagepage != 1)
        break label1357;
      if (this.m_pReports[j].pInputs[i2].pUsages[i5] != 48)
        break label859;
      int i26 = 0;
      if ((1 << -1 + this.m_pReports[j].pInputs[i2].sizebits & arrayOfInt[i5]) != 0)
        i26 = 1;
      if (i26 == 1)
      {
        i28 = 0;
        i29 = 0;
//        label742:
        	int i30 = this.m_pReports[j].pInputs[i2].sizebits;
        if (i29 < i30)
          break label845;
        arrayOfInt[i5] = (i28 ^ arrayOfInt[i5]);
      }
      int i27 = (1 - i26 * 2) * arrayOfInt[i5];
      if (this.m_pReports[j].pInputs[i2].logicalmax - this.m_pReports[j].pInputs[i2].logicalmin == 0);
      this.poutAction.Mouse_X = i27;
    }
    label1330: label1863: 
    while (true)
    {
      i5++;
      break label629;
      break;
      label845: i28 = 0x1 | i28 << 1;
      i29++;
      break label742;
      label859: if (this.m_pReports[j].pInputs[i2].pUsages[i5] == 49)
      {
        int i21 = 0;
        if ((1 << -1 + this.m_pReports[j].pInputs[i2].sizebits & arrayOfInt[i5]) != 0)
          i21 = 1;
        int i23;
        if (i21 == 1)
          i23 = 0;
        for (int i24 = 0; ; i24++)
        {
          int i25 = this.m_pReports[j].pInputs[i2].sizebits;
          if (i24 >= i25)
          {
            arrayOfInt[i5] = (i23 ^ arrayOfInt[i5]);
            int i22 = (1 - i21 * 2) * arrayOfInt[i5];
            if (this.m_pReports[j].pInputs[i2].logicalmax - this.m_pReports[j].pInputs[i2].logicalmin == 0);
            this.poutAction.Mouse_Y = i22;
            break;
          }
          i23 = 0x1 | i23 << 1;
        }
      }
      if (this.m_pReports[j].pInputs[i2].pUsages[i5] == 56)
      {
        int i16 = 0;
        if ((1 << -1 + this.m_pReports[j].pInputs[i2].sizebits & arrayOfInt[i5]) != 0)
          i16 = 1;
        int i18;
        if (i16 == 1)
          i18 = 0;
        for (int i19 = 0; ; i19++)
        {
          int i20 = this.m_pReports[j].pInputs[i2].sizebits;
          if (i19 >= i20)
          {
            arrayOfInt[i5] = (i18 ^ arrayOfInt[i5]);
            int i17 = (1 - i16 * 2) * arrayOfInt[i5];
            if (this.m_pReports[j].pInputs[i2].logicalmax - this.m_pReports[j].pInputs[i2].logicalmin == 0);
            this.poutAction.Mouse_Wheel = i17;
            break;
          }
          i18 = 0x1 | i18 << 1;
        }
      }
      if (i1 != 128)
        continue;
      int i13 = 0;
      if (arrayOfInt[i5] == this.m_pReports[j].pInputs[i2].logicalmin)
        i13 = 0;
      int i14;
      while (true)
      {
        i14 = 1 << i5;
        if (i13 == 0)
          break label1330;
        this.poutAction.KB_Power = (i14 | this.poutAction.KB_Power);
        break;
        if (arrayOfInt[i5] != this.m_pReports[j].pInputs[i2].logicalmax)
          continue;
        i13 = 1;
      }
      int i15 = i14 ^ 0xFFFFFFFF;
      this.poutAction.KB_Power = (i15 & this.poutAction.KB_Power);
      continue;
      label1357: if (this.m_pReports[j].pInputs[i2].usagepage == 9)
      {
        if ((this.m_pReports[j].pInputs[i2].pUsages[i5] < 1) || (this.m_pReports[j].pInputs[i2].pUsages[i5] > 8))
          continue;
        int i10 = 0;
        if (arrayOfInt[i5] == this.m_pReports[j].pInputs[i2].logicalmin)
          i10 = 0;
        int i11;
        while (true)
        {
          i11 = 1 << i5;
          if (i10 == 0)
            break label1516;
          this.poutAction.Mouse_Buts = (i11 | this.poutAction.Mouse_Buts);
          break;
          if (arrayOfInt[i5] != this.m_pReports[j].pInputs[i2].logicalmax)
            continue;
          i10 = 1;
        }
//        label1516:
        	int i12 = i11 ^ 0xFFFFFFFF;
        this.poutAction.Mouse_Buts = (i12 & this.poutAction.Mouse_Buts);
        continue;
      }
      if (this.m_pReports[j].pInputs[i2].usagepage == 7)
      {
        if ((this.m_pReports[j].pInputs[i2].pUsages[i5] < 224) || (this.m_pReports[j].pInputs[i2].pUsages[i5] > 231))
          continue;
        int i7 = 0;
        if (arrayOfInt[i5] == this.m_pReports[j].pInputs[i2].logicalmin)
          i7 = 0;
        int i8;
        while (true)
        {
          i8 = 1 << i5;
          if (i7 == 0)
            break label1705;
          this.poutAction.KB_Modifier = (i8 | this.poutAction.KB_Modifier);
          break;
          if (arrayOfInt[i5] != this.m_pReports[j].pInputs[i2].logicalmax)
            continue;
          i7 = 1;
        }
        int i9 = i8 ^ 0xFFFFFFFF;
        this.poutAction.KB_Modifier = (i9 & this.poutAction.KB_Modifier);
        continue;
      }
      if (this.m_pReports[j].pInputs[i2].usagepage != 12)
        continue;
      int i6 = 0;
      if (arrayOfInt[i5] == this.m_pReports[j].pInputs[i2].logicalmin)
        i6 = 0;
      while (true)
      {
        if (i5 >= 255)
          break label1863;
        this.poutAction.EK_BufKeys[i5] = i6;
        this.poutAction.EK_BufUses[i5] = this.m_pReports[j].pInputs[i2].pUsages[i5];
        break;
        if (arrayOfInt[i5] != this.m_pReports[j].pInputs[i2].logicalmax)
          continue;
        i6 = 1;
      }
    }
	return i29;
  }

  protected void finalize()
    throws Throwable
  {
    super.finalize();
    Deinit();
  }

  class _HIDREPORT
  {
    int collection;
    int id;
    int nInputs;
    HidParser._INPUT[] pInputs = new HidParser._INPUT[1];
    int usage;
    int usagepage;

    _HIDREPORT()
    {
    }
  }

  class _INPUT
  {
    int logicalmax;
    int logicalmin;
    int nUsages;
    int[] pUsages = new int[1];
    int sizebits;
    int sizecount;
    int type;
    int usagemax;
    int usagemin;
    int usagepage;

    _INPUT()
    {
    }
  }

  class _LAST
  {
    int logicalmax;
    int logicalmin;
    int nUsages;
    int[] pUsages;
    int sizebits;
    int sizecount;
    int type;
    int usagemax;
    int usagemin;
    int usagepage;

    _LAST()
    {
    }
  }

  class _TOPCOLLECTION
  {
    int usage;
    int usagepage;

    _TOPCOLLECTION()
    {
    }
  }
}